﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace CopyIt
{
    public partial class DisplayPairs : UserControl
    {
        public event EventHandler InvertSourceDest;

        private string[] OverrideMode = new string[] { "Ignora", "Sovrascrivi", "Sovrascrivi se differente", "Sovrascrivi se più nuovo" };
        private string[] WriteMode = new string[] { "Sovrascrivi il vecchio file", "Copia nel cestino il vecchio file", "Rinomina il vecchio file" };
        public DisplayPairs()
        {
            InitializeComponent();
        }

        private void DisplayPairs_Paint(object sender, PaintEventArgs e)
        {
            Rectangle TopRect = this.ClientRectangle;
            PointF lF = new PointF(TopRect.Left + 10, 45);
            PointF rF = new PointF(TopRect.Right - 10, 45);

            e.Graphics.DrawLine(new Pen(Color.FromArgb(125, 152, 193)), lF, rF);
        }

        public void SetParams(PairsParameters Params)
        {
            lblPairsName.Text = Params.PairsName;
            lblSource.Text = Params.SourceFolder;
            lblDest.Text = Params.DestFolder;
            lblHidden.ForeColor = (Params.ExcludeTypes & System.IO.FileAttributes.Hidden) != 0 ? Color.MidnightBlue : Color.LightGray;
            lblSystem.ForeColor = (Params.ExcludeTypes & System.IO.FileAttributes.System) != 0 ? Color.MidnightBlue : Color.LightGray;
            lblReadOnly.ForeColor = (Params.ExcludeTypes & System.IO.FileAttributes.ReadOnly) != 0 ? Color.MidnightBlue : Color.LightGray;
            lblInclude.ForeColor = Params.EnableIncludeFilter ? Color.MidnightBlue : Color.LightGray;
            lblExclude.ForeColor = Params.EnableExcludeFilter ? Color.MidnightBlue : Color.LightGray;
            lblInclude.Text = Params.CurrentIncludeFilter;
            lblExclude.Text = Params.CurrentExcludeFilter;
            lblOverride.Text = OverrideMode[(int)Params.Override];
            lblWriteMode.Text = WriteMode[(int)Params.Writemode];
            lblLastBackup.Text = (Params.LastBackup != DateTime.MinValue) ? Params.LastBackup.ToString("dd MMM yyyy HH:mm") : "";
        }

        private void imgInvert_Click(object sender, EventArgs e)
        {
            if (InvertSourceDest != null)
                InvertSourceDest(this, new EventArgs());

            string tmp = string.Format("Sorgente:\t{0}\r\nDestinazione:\t{1}", lblSource.Text, lblDest.Text);
            MessageBox.Show(this, tmp, "Invertita sorgente con destinazione", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}
